﻿
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@model CGT.Infrastructure.Entity.GovSystemSetting
<section class="content-header">
    <h1>
        系统设置
        <small></small>
    </h1>
    <ol class="breadcrumb"></ol>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <div class="box-header">

                </div>
                <!-- /.box-header -->
                <div class="box-body table-responsive no-padding">
                    <form id="form1" class="form-horizontal bv-form" novalidate="novalidate">
                        <input type="hidden" value="@Model.SettingID" name="SettingID" id="SettingID" />
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="name">IP(终端)锁定阀值：</label>
                            <div class="col-sm-3">
                                <input class="form-control" style="width:300px;" placeholder="次" value="@Model.IPLockThreshold"  name="IPLockThreshold" id="IPLockThreshold" type="number" >
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="name">用户锁定阀值：</label>
                            <div class="col-sm-3">
                                <input class="form-control" style="width:300px;" placeholder="次" value="@Model.UserLockThreshold" name="UserLockThreshold" id="UserLockThreshold" type="number">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="name">登录超时时间：</label>
                            <div class="col-sm-3">
                                <input class="form-control" style="width:300px;" placeholder="分钟" value="@Model.LoginExpire" name="LoginExpire" id="LoginExpire" type="number">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="name">用户最大会话数：</label>
                            <div class="col-sm-3">
                                <input class="form-control" style="width:300px;" placeholder="个" value="@Model.UserSessionMax" name="UserSessionMax" id="UserSessionMax" type="number">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="name">用户登录高频限制：</label>
                            <div class="col-sm-3">
                                <input class="form-control" style="width:300px;" placeholder="次/小时" value="@Model.UserLoginTimesMax" name="UserLoginTimesMax" id="UserLoginTimesMax" type="number">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="name">用户长期未使用限制：</label>
                            <div class="col-sm-3">
                                <input class="form-control" style="width:300px;" placeholder="天" value="@Model.UserUnuseTimeMax" name="UserUnuseTimeMax" id="UserUnuseTimeMax" type="number">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="name">登录日志存储期限：</label>
                            <div class="col-sm-3">
                                <input class="form-control" style="width:300px;" placeholder="天" value="@Model.LogingSaveDays" name="LogingSaveDays" id="LogingSaveDays" type="number">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="name">操作日志存储期限：</label>
                            <div class="col-sm-3">
                                <input class="form-control" style="width:300px;" placeholder="天" value="@Model.OperateSaveDays" name="OperateSaveDays" id="OperateSaveDays" type="number">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="name">安全日志存储期限：</label>
                            <div class="col-sm-3">
                                <input class="form-control" style="width:300px;" placeholder="天" value="@Model.SafeSaveDays" name="SafeSaveDays" id="SafeSaveDays" type="number">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label" for="name">接口日志存储期限：</label>
                            <div class="col-sm-3">
                                <input class="form-control" style="width:300px;" placeholder="天" value="@Model.InterfaceSaveDays" name="InterfaceSaveDays" id="InterfaceSaveDays" type="number">
                            </div>
                        </div>
                    </form>
                </div>
                <div class="box-footer text-center">
                    <button class="btn btn-primary" type="button" id="btnSave">确 定 </button>
                    <button class="btn" type="button" id="btnCancel">取 消 </button>
                </div>
                <!-- /.box-body -->
                <!-- /.box -->
            </div>
        </div>
    </div>
</section>
@section scriptsBottom{
    <script type="text/javascript">
        $(document).ready(function () {
            initFormValidate();
            $("#btnSave").click(function () {
                save();
            });
            $("#btnCancel").click(function () {
                cancel();
            });
        });

        function initFormValidate() {
            $("#form1").bootstrapValidator({
                submitHandler: function (valiadtor, loginForm, submitButton) {
                    valiadtor.defaultSubmit();
                },
                fields: {
                    IPLockThreshold: {
                        validators: {
                            notEmpty: {
                                message: 'IP锁定(终端锁定)阀值不能为空'
                            },
                            regexp: {
                                regexp: /^[1-9][0-9]*$/,
                                message: '请输入数字(大于0)'
                            }
                        }
                    },
                    UserLockThreshold: {
                        validators: {
                            notEmpty: {
                                message: '用户锁定阀值不能为空'
                            },
                            regexp: {
                                regexp: /^[1-9][0-9]*$/,
                                message: '请输入数字(大于0)'
                            }
                        }
                    },
                    LoginExpire: {
                        validators: {
                            notEmpty: {
                                message: '登录超时时间值不能为空'
                            },
                            regexp: {
                                regexp: /^[1-9][0-9]*$/,
                                message: '请输入数字(大于0)'
                            }
                        }
                    },
                    UserSessionMax: {
                        validators: {
                            notEmpty: {
                                message: '用户最大会话数字不能为空'
                            },
                            regexp: {
                                regexp: /^[1-9][0-9]*$/,
                                message: '请输入数字(大于0)'
                            }
                        }
                    },
                    UserLoginTimesMax: {
                        validators: {
                            notEmpty: {
                                message: '用户登录高频限制值不能为空'
                            },
                            regexp: {
                                regexp: /^[1-9][0-9]*$/,
                                message: '请输入数字(大于0)'
                            }
                        }
                    },
                    UserUnuseTimeMax: {
                        validators: {
                            notEmpty: {
                                message: '用户长期未使用限制值不能为空'
                            },
                            regexp: {
                                regexp: /^[1-9][0-9]*$/,
                                message: '请输入数字(大于0)'
                            }
                        }
                    },
                    LogingSaveDays: {
                        validators: {
                            notEmpty: {
                                message: '登录日志存储期限值不能为空'
                            },
                            regexp: {
                                regexp: /^[1-9][0-9]*$/,
                                message: '请输入数字(大于0)'
                            }
                        }
                    },
                    OperateSaveDays: {
                        validators: {
                            notEmpty: {
                                message: '操作日志存储期限值不能为空'
                            },
                            regexp: {
                                regexp: /^[1-9][0-9]*$/,
                                message: '请输入数字(大于0)'
                            }
                        }
                    },
                    SafeSaveDays: {
                        validators: {
                            notEmpty: {
                                message: '安全日志存储期限值不能为空'
                            },
                            regexp: {
                                regexp: /^[1-9][0-9]*$/,
                                message: '请输入数字(大于0)'
                            }
                        }
                    },
                    InterfaceSaveDays: {
                        validators: {
                            notEmpty: {
                                message: '接口日志存储期限不能为空'
                            },
                            regexp: {
                                regexp: /^[1-9][0-9]*$/,
                                message: '请输入数字(大于0)'
                            }
                        }
                    }
                }
            });
        }

        //保存
        function save()
        {
            var bootstrapValidator = $("#form1").data('bootstrapValidator');
            bootstrapValidator.validate();

            if (bootstrapValidator.isValid()) {
                var arrData = $("#form1").serializeArray();
                var data = {};
                for (var i = 0; i < arrData.length; i++) {
                    data[arrData[i].name] = arrData[i].value;
                }

                BMCW.ajax({
                    url: '@Url.Action("Save","SystemSetting")',
                    type: "POST",
                    data:data,
                    success: function (rt) {
                        if (rt.status == 0) {
                            BMCW.msg("保存成功",function(){
                            });
                        } else {
                            BMCW.alert("保存失败");
                        }
                    }
                })
            }
        }

        //取消，跳回上一页面
        function cancel()
        {
            history.go(-1);
        }
    </script>
}

